﻿#include "Articles.h"
#include"Game.h"
Articles::Articles()
{
	setType(Type::items);
}

Articles::Articles(int x, int y) :Background(x, y)
{
	setType(Type::items);
}

void Articles::init()
{
	setType(Type::items);
}

void Articles::update()
{

}

void Articles::draw(QPainter* painter)
{
	if(isActive())
		getModel()["正常"].draw(painter, getPos());
}



void Articles::setWindow(const QRect& rect)
{
	m_Window=rect;
}

void Articles::setWindowSize(const QSize& size)
{
	m_Window.setSize(size);
}

const QSize Articles::getWindowSize()
{
	//return m_windowSize;
	return m_Window.size();
}

void Articles::setCollider(const QPainterPath& collider)
{
	m_collider = collider;
}

void Articles::setCollider(const QRect& rect)
{
	m_collider.clear();
	m_collider.addRect(rect);
}

void Articles::setCollider(const QPoint& pos, const qreal rx, const qreal ry)
{
	m_collider.clear();
	m_collider.addEllipse(pos,rx,ry);
}

QPainterPath& Articles::getCollider()
{
	return m_collider;
}

const QRect& Articles::getWindow()
{
	return m_Window;
}

bool Articles::Collider(const QPainterPath& collider)
{
	return m_collider.intersects(collider);
}

bool Articles::Collider(const QRect& rect)
{
	QPainterPath path;
	path.addRect(rect);
	return m_collider.intersects(path);
}

bool Articles::Collider(Articles& art)
{
	return Collider(art.getCollider());
}
void Articles::reduceHp(const int hp)
{
	m_Hp -= hp;
	if (m_Hp <0)
		m_Hp=0;
}
void Articles::addHp(const int hp)
{
	m_Hp += hp;
}
//bool Articles::Collider(Articles* art)
//{
//	return Collider(art->getModelRect());
//}
void Articles::setHp(int HP)
{
	m_Hp = HP;
}

int Articles::getHp()
{
	return m_Hp;
}
void Articles::setMaxHp(int HP)
{
	m_maxHp = HP;
}
int Articles::getMaxHP()
{
	return m_maxHp;
}

